//
//  @ Project : Adamantium Project
//  @ File Name : SRMap.cpp
//  @ Date : 12/3/2012
//  @ Author : 
//
//


#include "SRMap.h"

SRMap::SRMap() {
	superNova = false;
	isDarkSpace = false;
	isExplored = false;
	//enemy pos and star pos set to null for now. will set with init
}

void SRMap::init(int level) {
	//level used to mark difficulty? probably better to fill from a main area 
}//no need to init. use other functions for adding and removing 
//enemies and stellar objects.

SRMap::~SRMap()
{
	enemyPos.release();
	starPos.release();
}
/** add enemy pos to quadrant or SRMap*/
void SRMap::addEnemyPos(V2DI a_pos)
{
	enemyPos.add( a_pos);
}
/** add star to quadrant or SRMap*/
void SRMap::addStarPos(V2DI a_pos)
{
	starPos.add( a_pos);
}
/** removes enemy from specific pos. returns true if successful */
bool SRMap::removeEnemy(V2DI a_pos)
{
	for(int i = 0; i < enemyPos.size(); ++i) {
		if( (enemyPos[i].x == a_pos.x) && (enemyPos[i].y == a_pos.y)) {
			enemyPos.remove(i);
			return true;//true has removed enemy from map
		}
	}
	return false;//false has failed to remove enemy from map.
}
/** checks to see if an object is at a_pos*/
bool SRMap::checkObjectAt(V2DI a_pos)
{
	for(int i = 0; i < enemyPos.size(); ++i) {
		if( (enemyPos[i].x == a_pos.x) && (enemyPos[i].y == a_pos.y)) {
			return true;//true for spot is filled by enemy
		}
	}

	for(int i = 0; i < starPos.size(); ++i) {
		if( (starPos[i].x == a_pos.x) && (starPos[i].y == a_pos.y)) {
			return true;//true for spot is filled by star
		}
	}
	return false;//false for no enemy on pos.
}

int SRMap::enemyNumbers()
{
	return enemyPos.size();
}

int SRMap::starNumbers()
{
	return starPos.size();
}

TemplateVector<V2DI> SRMap::getEnemyPos()
{
	TemplateVector<V2DI> a_enemyPos = enemyPos;
	return a_enemyPos;
}

TemplateVector<V2DI> SRMap::getStarPos()
{
	TemplateVector<V2DI> a_starPos = starPos;
	return a_starPos;
}

//bool SRMap::checkSuperNova()
//{
//	return superNova;
//}
//
//bool SRMap::checkDarkSpace()
//{
//	return isDarkSpace;
//}